//var $j = jQuery.noConflict();
/* uncomment this block if there are some conflicts with other js library/framework */
(function ($) {

MyPage = {
    element: {
        btnSelectAllServices: null
		, btnReset: null
		, frmSearch: null
    },

    builder: {},

    application: {
		resetForm: function ( ){
			MyPage.element.frmSearch.find('input:checkbox[name="chkServiceType[]"]').attr('checked' , false ).attr('selected' , false );
		}
		
    },

    prepareElement: function () {
        this.element = {
            btnSelectAllServices: $("#btnSelectAllServices")
			, btnReset: $("#btnReset")
			, frmSearch: $("#frmSearch")
        };
    },

    prepareView: function () {
        this.element.btnSelectAllServices.button();
		this.element.btnReset.button();
    },

    eventBinding: function () {
        this.element.btnSelectAllServices.click(function () {
			MyPage.element.frmSearch.find('input:checkbox').attr('checked' , true ).attr('selected' , true );
        });
        this.element.btnReset.click(function () {
			MyPage.application.resetForm();
        });
        this.element.frmSearch.submit(function () {
			var isChecked = MyPage.element.frmSearch.find('input[name="chkServiceType[]"]:checked');
			if ( ! isChecked.length)
			{
				App.alert("Please select at least one Service" , "" )
				return false;
			}
        });
		
		this.element.frmSearch.delegate('.btnOrganisation', 'click', function () {
			var id = $(this).attr("itemprop");
			$("#hidOrganisationType").val(id);
			MyPage.element.frmSearch.submit();
        });

    },

    main: function () {
        this.prepareElement();
        this.prepareView();
        this.eventBinding();
    }
};

$(function () {
    MyPage.main();
});

/* uncomment this block if there are some conflicts with other js library/framework */
})(jQuery);

